package com.design.working.dao.impl;

import com.design.working.dao.StudentDAO;
import com.design.working.dto.StudentWorkApplicationDTO;
import com.design.working.dto.StudentWorkMotionDTO;
import com.design.working.dto.student.UpdateIndividualInformationDTO;
import com.design.working.po.student.SelectAllWorkPO;
import com.design.working.po.student.StudentSalaryPO;
import com.design.working.util.JDBCUtil;
import com.design.working.vo.student.IndividualInformationByUidVO;
import com.design.working.po.student.StudentWorkApplicationRecordPO;
import com.design.working.vo.student.JobSelectionVO;
import com.design.working.vo.student.StudentCurrentWorkVO;
import com.design.working.vo.student.StudentWorkAttendanceVO;

import java.sql.*;
import java.util.ArrayList;
import java.util.List;

import static com.design.working.enums.OperationEnum.*;

/**
 * @author gavin
 * @date 2022/5/9 12:12
 */
public class StudentDAOImpl implements StudentDAO {

    /**
     * 用于selectSalary中的type:上个月
     */
    private static final String LAST_MONTH = "lastMonth";

    /**
     * 缺勤, 0
     */
    private static final int NOT_ATTEND = 0;

    /**
     * 出勤, 1
     */
    private static final int ATTEND = 1;

    /**
     * 请假, 2
     */
    private static final int LEAVE = 2;


    /**
     * （申请岗位）查找全部岗位
     *
     * @param place 需要查询的岗位所属的行政分类（job_category）
     * @param page  分页当前页码
     * @param limit 分页每页展示数据
     * @return 查询到的岗位
     */
    @Override
    public List<JobSelectionVO> selectJob(String place, Integer page, Integer limit) {

        List<JobSelectionVO> list = new ArrayList<>();
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;

        try {
            connection = JDBCUtil.getConnection();
            // 四表联结
            String sql = "SELECT DISTINCT job.id, dept.name, job.name, dept_employee.username, job.place, job.salary, job_remain.remain, job.detail " +
                    "FROM dept, job, dept_employee, job_remain, job_category " +
                    "WHERE job.dept_id = dept.id AND job.dept_employee_id = dept_employee.id " +
                    "AND job.job_category_id = (SELECT job_category.id FROM job_category WHERE job_category.name = ?) " +
                    "AND job.id = job_remain.job_id AND job.is_deleted = 0";
            if (!page.equals(NO_PAGE.getVal())) {
                sql += " limit ?,?";
            }

            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setString(1, place);
            if (!page.equals(NO_PAGE.getVal())) {
                preparedStatement.setInt(2, page);
                preparedStatement.setInt(3, limit);
            }
            resultSet = preparedStatement.executeQuery();

            while (resultSet.next()) {
                list.add(new JobSelectionVO(resultSet.getInt(1),
                        resultSet.getString(2),
                        resultSet.getString(3),
                        resultSet.getString(4),
                        resultSet.getString(5),
                        resultSet.getBigDecimal(6),
                        resultSet.getInt(7),
                        resultSet.getString(8), 1));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JDBCUtil.close(resultSet, preparedStatement, connection);
        }
        return list;
    }

    /**
     * 查询学生是否有在申请的岗位
     *
     * @param uid 学生学号
     * @return true-有; false-没有
     */
    @Override
    public boolean isStudentInApplying(Integer uid) {
        boolean flag = true;
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;

        try {
            connection = JDBCUtil.getConnection();
            String sql = "SELECT student_work_application.id " +
                    "FROM student_msg_template " +
                    "JOIN student_work_application " +
                    "ON student_work_application.student_msg_template_id = student_msg_template.id " +
                    "AND student_work_application.is_admin_passed = 0 " +
                    "AND student_msg_template.student_uid = ? " +
                    "AND student_work_application.is_deleted = 0";

            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setInt(1, uid);
            resultSet = preparedStatement.executeQuery();
            if (resultSet.next()) {
                flag = false;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JDBCUtil.close(resultSet, preparedStatement, connection);
        }
        return flag;
    }

    /**
     * 查询学生是否有工作
     *
     * @param uid 学生学号
     * @return true-有; false-没有
     */
    @Override
    public boolean isStudentInWorking(Integer uid) {
        boolean flag = true;
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;

        try {
            connection = JDBCUtil.getConnection();
            String sql = "SELECT id " +
                    "FROM student_to_work " +
                    "WHERE student_uid = ? " +
                    "AND status = 1 " +
                    "AND is_admin_passed = 1 " +
                    "AND is_deleted = 0;";

            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setInt(1, uid);
            resultSet = preparedStatement.executeQuery();
            if (resultSet.next()) {
                flag = false;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JDBCUtil.close(resultSet, preparedStatement, connection);
        }
        return flag;
    }

    /**
     * 插入学生申请的岗位
     *
     * @param uid                       学生学号
     * @param studentWorkApplicationDTO 前端表单传来的信息
     */
    @Override
    public void insertStudentWorkApplication(Integer uid, StudentWorkApplicationDTO studentWorkApplicationDTO) {

        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;

        try {
            connection = JDBCUtil.getConnection();
            // 取消自动提交（事务）
            connection.setAutoCommit(false);
            // 加入行锁，保证岗位容量正确
            String sql = "SELECT id, remain FROM job_remain where job_id = ? FOR UPDATE";
            String sql1 = "SELECT class_id FROM student_msg where uid = ?";
            String sql2 = "INSERT INTO student_msg_template(student_uid, phone, email, political_status, " +
                    "needy_student, dorm, class_id, strength, free_time) VALUES (?,?,?,?,?,?,?,?,?);";
            String sql3 = "INSERT INTO student_work_application(student_msg_template_id, job_id) VALUES (?, ?);";
            String sql4 = "UPDATE job_remain SET remain = ? where id = ?";

            // 先查询岗位余量，不满足则回滚事务
            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setInt(1, studentWorkApplicationDTO.getId());
            resultSet = preparedStatement.executeQuery();
            int remainId = NO_INDEX.getVal();
            int remain = FULL_REMAIN.getVal();
            if (resultSet.next()) {
                remainId = resultSet.getInt(1);
                remain = resultSet.getInt(2);
            }

            // 没有余量则回滚
            if (remain <= NO_REMAIN.getVal()) {
                connection.rollback();
            } else {
                // 获取学生当前所在班级id（因为有可能转专业或者别的情况，所以是获取当前的）
                preparedStatement = connection.prepareStatement(sql1);
                preparedStatement.setInt(1, uid);
                resultSet = preparedStatement.executeQuery();
                int classId = -1;
                if (resultSet.next()) {
                    classId = resultSet.getInt(1);
                }

                // 将前端的个人信息插入，同时获取所插入值在表中的id，用作后面表的一个字段
                preparedStatement = connection.prepareStatement(sql2, PreparedStatement.RETURN_GENERATED_KEYS);
                preparedStatement.setInt(1, uid);
                preparedStatement.setString(2, studentWorkApplicationDTO.getPhone());
                preparedStatement.setString(3, studentWorkApplicationDTO.getEmail());
                preparedStatement.setString(4, studentWorkApplicationDTO.getPoliticalStatus());
                preparedStatement.setInt(5, studentWorkApplicationDTO.getNeedyStudent());
                preparedStatement.setString(6, studentWorkApplicationDTO.getDorm());
                preparedStatement.setInt(7, classId);
                preparedStatement.setString(8, studentWorkApplicationDTO.getStrength());
                preparedStatement.setString(9, studentWorkApplicationDTO.getFreeTime());
                preparedStatement.executeUpdate();
                // 获取插入的数据的id
                resultSet = preparedStatement.getGeneratedKeys();
                int id = NO_INDEX.getVal();
                if (resultSet.next()) {
                    id = resultSet.getInt(1);
                }

                // 在学生岗位申请表中创建申请记录
                preparedStatement = connection.prepareStatement(sql3);
                preparedStatement.setInt(1, id);
                preparedStatement.setInt(2, studentWorkApplicationDTO.getId());
                preparedStatement.executeUpdate();

                // 修改该岗位余量
                preparedStatement = connection.prepareStatement(sql4);
                remain -= 1;
                preparedStatement.setInt(1, remain);
                preparedStatement.setInt(2, remainId);
                preparedStatement.executeUpdate();

                // 提交事务
                connection.commit();

            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JDBCUtil.close(resultSet, preparedStatement, connection);
        }
    }

    /**
     * 查询学生目前在岗岗位
     *
     * @param uid 要查询的学生学号
     * @return 学生在岗岗位
     */
    @Override
    public List<StudentCurrentWorkVO> selectCurrentWork(Integer uid) {

        List<StudentCurrentWorkVO> list = new ArrayList<>();

        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;

        try {
            connection = JDBCUtil.getConnection();
            String sql = "SELECT student_to_work.id, dept.name, job.name, dept_employee.username, job.place, " +
                    "student_to_work.working_time, job.salary, job.detail, student_to_work.is_motion " +
                    "FROM student_to_work, job, dept_employee, dept " +
                    "WHERE student_to_work.student_uid = ? " +
                    "AND student_to_work.status = 1 " +
                    "AND student_to_work.is_admin_passed = 1 " +
                    "AND student_to_work.is_deleted = 0 " +
                    "AND job.id = student_to_work.job_id " +
                    "AND job.dept_id = dept.id " +
                    "AND job.dept_employee_id = dept_employee.id;";

            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setInt(1, uid);
            resultSet = preparedStatement.executeQuery();

            while (resultSet.next()) {
                list.add(new StudentCurrentWorkVO(resultSet.getInt(1),
                        resultSet.getString(2),
                        resultSet.getString(3),
                        resultSet.getString(4),
                        resultSet.getString(5),
                        resultSet.getString(6),
                        resultSet.getString(7),
                        resultSet.getString(8),
                        resultSet.getInt(9)));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JDBCUtil.close(resultSet, preparedStatement, connection);
        }
        return list;
    }

    /**
     * 查询学生所有的用工岗位
     *
     * @param uid   学生学号
     * @param page  分页当前页码
     * @param limit 分页每页展示数据
     * @return 学生所有的用工岗位
     */
    @Override
    public List<SelectAllWorkPO> selectAllWork(Integer uid, Integer page, Integer limit) {

        List<SelectAllWorkPO> list = new ArrayList<>();

        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;

        try {
            connection = JDBCUtil.getConnection();
            String sql = "SELECT student_to_work.id, campus_term.year, campus_term.term, dept.name, job.name, job.detail " +
                    "FROM student_to_work, job, dept, dept_employee, campus_term " +
                    "WHERE student_to_work.student_uid = ? " +
                    "AND student_to_work.is_deleted = 0 " +
                    "AND student_to_work.is_admin_passed = 1 " +
                    "AND student_to_work.job_id = job.id " +
                    "AND job.dept_id = dept.id " +
                    "AND job.dept_employee_id = dept_employee.id " +
                    "AND job.campus_term_id = campus_term.id";

            if (!page.equals(NO_PAGE.getVal())) {
                sql += " limit ?,?";
            }
            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setInt(1, uid);
            if (!page.equals(NO_PAGE.getVal())) {
                preparedStatement.setInt(2, page);
                preparedStatement.setInt(3, limit);
            }
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                list.add(new SelectAllWorkPO(resultSet.getInt(1),
                        resultSet.getInt(2),
                        resultSet.getInt(3),
                        resultSet.getString(4),
                        resultSet.getString(5),
                        resultSet.getString(6)
                ));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JDBCUtil.close(resultSet, preparedStatement, connection);
        }
        return list;
    }

    /**
     * 查询学生考勤记录
     *
     * @param id    student_to_work的id
     * @param page  分页当前页码
     * @param limit 分页每页展示数据
     * @return 对应工作的考勤记录
     */
    @Override
    public List<StudentWorkAttendanceVO> selectAttendanceById(Integer id, Integer page, Integer limit) {

        List<StudentWorkAttendanceVO> list = new ArrayList<>();

        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;

        try {
            connection = JDBCUtil.getConnection();
            String sql = "SELECT student_work_attendance.working_date, student_work_attendance.is_attend, dept_employee.username " +
                    "FROM student_work_attendance, student_to_work, job, campus_term, dept_employee, dept " +
                    "WHERE student_work_attendance.is_deleted = 0 " +
                    "AND student_work_attendance.student_to_work_id = student_to_work.id " +
                    "AND student_to_work.id = ? " +
                    "AND student_to_work.job_id = job.id " +
                    "AND student_work_attendance.dept_employee_id = dept_employee.id " +
                    "AND job.dept_id = dept.id " +
                    "AND job.campus_term_id = campus_term.id";

            if (!page.equals(NO_PAGE.getVal())) {
                sql += " limit ?,?";
            }

            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setInt(1, id);
            if (!page.equals(NO_PAGE.getVal())) {
                preparedStatement.setInt(2, page);
                preparedStatement.setInt(3, limit);
            }
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                String attend = null;
                switch (resultSet.getInt(2)) {
                    case NOT_ATTEND:
                        attend = "缺勤";
                        break;
                    case ATTEND:
                        attend = "出勤";
                        break;
                    case LEAVE:
                        attend = "请假";
                        break;
                    default:
                }
                list.add(new StudentWorkAttendanceVO(
                        resultSet.getDate(1).toLocalDate().toString(),
                        attend,
                        resultSet.getString(3)
                ));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JDBCUtil.close(resultSet, preparedStatement, connection);
        }
        return list;
    }

    /**
     * 插入学生申请岗位变更数据
     *
     * @param studentWorkMotionDTO 前端传来的申请数据
     */
    @Override
    public void insertStudentWorkMotion(StudentWorkMotionDTO studentWorkMotionDTO) {

        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;

        try {
            connection = JDBCUtil.getConnection();
            // 开启事务
            connection.setAutoCommit(false);
            String sql1 = "SELECT job.dept_employee_id " +
                    "FROM student_to_work, job " +
                    "WHERE student_to_work.id = ? " +
                    "AND student_to_work.is_deleted = 0 " +
                    "AND student_to_work.is_admin_passed = 1 " +
                    "AND student_to_work.status = 1 " +
                    "AND student_to_work.job_id = job.id";
            preparedStatement = connection.prepareStatement(sql1);
            preparedStatement.setInt(1, studentWorkMotionDTO.getStudentToWorkId());
            // 1. 先查询该工作的负责老师id
            resultSet = preparedStatement.executeQuery();
            int deptEmployeeId = NO_INDEX.getVal();
            if (resultSet.next()) {
                deptEmployeeId = resultSet.getInt(1);
            }
            if (deptEmployeeId <= NOT_FIND_INDEX.getVal()) {
                connection.rollback();
            } else {
                String sql2 = "INSERT INTO student_work_motion(student_to_work_id, work_type, student_explanation, dept_employee_id) " +
                        "VALUES (?, ?, ?, ?)";
                preparedStatement = connection.prepareStatement(sql2);
                preparedStatement.setInt(1, studentWorkMotionDTO.getStudentToWorkId());
                preparedStatement.setInt(2, studentWorkMotionDTO.getWorkType());
                preparedStatement.setString(3, studentWorkMotionDTO.getStudentExplanation());
                preparedStatement.setInt(4, deptEmployeeId);
                // 2. 插入学生的变更记录
                preparedStatement.executeUpdate();

                String sql3 = "UPDATE student_to_work SET is_motion = 1 WHERE id = ?";
                preparedStatement = connection.prepareStatement(sql3);
                preparedStatement.setInt(1, studentWorkMotionDTO.getStudentToWorkId());
                // 3. 将该学生的工作设置为待处理状态
                preparedStatement.executeUpdate();

                // 提交事务
                connection.commit();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JDBCUtil.close(resultSet, preparedStatement, connection);
        }
    }

    /**
     * 查询学生所有的岗位记录
     *
     * @param uid   学生学号
     * @param page  分页当前页码
     * @param limit 分页每页展示数据
     * @return 该生的所有申请岗位记录
     */
    @Override
    public List<StudentWorkApplicationRecordPO> selectAllWorkApplication(Integer uid, Integer page, Integer limit) {

        List<StudentWorkApplicationRecordPO> list = new ArrayList<>();
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;

        try {
            connection = JDBCUtil.getConnection();
            String sql = "SELECT campus_term.year, campus_term.term, dept.name, job.name, " +
                    "swa.is_counselor_passed, swa.is_dept_passed, swa.is_admin_passed, " +
                    "job.detail, swa.counselor_text ,swa.dept_text, swa.admin_text " +
                    "FROM student_work_application as swa, student_msg_template, job, dept, campus_term " +
                    "WHERE swa.student_msg_template_id = student_msg_template.id " +
                    "AND student_msg_template.student_uid = ? " +
                    "AND swa.job_id = job.id " +
                    "AND swa.is_deleted = 0 " +
                    "AND job.campus_term_id = campus_term.id " +
                    "AND job.dept_id = dept.id";
            if (!page.equals(NO_PAGE.getVal())) {
                sql += " limit ?,?";
            }

            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setInt(1, uid);
            if (!page.equals(NO_PAGE.getVal())) {
                preparedStatement.setInt(2, page);
                preparedStatement.setInt(3, limit);
            }
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {

                list.add(new StudentWorkApplicationRecordPO(
                        resultSet.getInt(1),
                        resultSet.getInt(2),
                        resultSet.getString(3),
                        resultSet.getString(4),
                        resultSet.getInt(5),
                        resultSet.getInt(6),
                        resultSet.getInt(7),
                        resultSet.getString(8),
                        resultSet.getString(9),
                        resultSet.getString(10),
                        resultSet.getString(11)
                ));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JDBCUtil.close(resultSet, preparedStatement, connection);
        }
        return list;
    }

    /**
     * 查询学生历史工资
     *
     * @param uid   学生学号
     * @param type  all-查询历史工资；lastMonth-上个月工资(定义在了常量LAST_MONTH)
     * @param page  分页当前页码
     * @param limit 分页每页展示数据
     * @return 学生的工资信息
     */
    @Override
    public List<StudentSalaryPO> selectSalary(Integer uid, String type, Integer page, Integer limit) {

        List<StudentSalaryPO> list = new ArrayList<>();
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;

        try {
            connection = JDBCUtil.getConnection();
            String sql = "SELECT campus_term.year, campus_term.term, student_work_salaries.salary_date, dept.name, " +
                    "job.name, student_work_salaries.salary, student_work_salaries.is_salary_settled " +
                    "FROM student_to_work " +
                    "JOIN student_work_salaries " +
                    "ON student_work_salaries.student_to_work_id = student_to_work.id " +
                    "JOIN job " +
                    "ON student_to_work.job_id = job.id " +
                    "JOIN dept " +
                    "ON job.dept_id = dept.id " +
                    "JOIN campus_term " +
                    "ON job.campus_term_id = campus_term.id " +
                    "WHERE student_to_work.student_uid = ? " +
                    "AND student_to_work.is_deleted = 0 " +
                    "AND student_work_salaries.is_deleted = 0";
            if (LAST_MONTH.equals(type)) {
                sql += " AND date_format(student_work_salaries.salary_date, '%Y-%m') = date_format(now(), '%Y-%m')";
            }
            if (!page.equals(NO_PAGE.getVal())) {
                sql += " limit ?,?";
            }

            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setInt(1, uid);
            if (!page.equals(NO_PAGE.getVal())) {
                preparedStatement.setInt(2, page);
                preparedStatement.setInt(3, limit);
            }
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {

                list.add(new StudentSalaryPO(
                        resultSet.getInt(1),
                        resultSet.getInt(2),
                        resultSet.getDate(3).toLocalDate(),
                        resultSet.getString(4),
                        resultSet.getString(5),
                        resultSet.getBigDecimal(6),
                        resultSet.getInt(7)
                ));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JDBCUtil.close(resultSet, preparedStatement, connection);
        }
        return list;
    }

    /**
     * 通过学号查询个人信息
     *
     * @param uid 学号
     * @return 相关的个人信息
     */
    @Override
    public IndividualInformationByUidVO selectIndividualInformationByUid(Integer uid) {

        IndividualInformationByUidVO individualInformationByUidVO = null;

        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;

        try {
            connection = JDBCUtil.getConnection();
            String sql = "SELECT s.uid, s.username, sm.gender, sm.phone, sm.email, sm.political_status, sm.is_needy_student, sm.dorm, sm.strength " +
                    "FROM student_msg sm " +
                    "JOIN student s on sm.uid = s.uid " +
                    "WHERE sm.uid = ? " +
                    "AND sm.is_deleted = 0";

            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setInt(1, uid);
            resultSet = preparedStatement.executeQuery();

            if (resultSet.next()) {
                individualInformationByUidVO = new IndividualInformationByUidVO(
                        resultSet.getInt(1),
                        resultSet.getString(2),
                        resultSet.getString(3),
                        resultSet.getString(4),
                        resultSet.getString(5),
                        resultSet.getString(6),
                        resultSet.getString(7),
                        resultSet.getString(8),
                        resultSet.getString(9)
                );
            }

        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JDBCUtil.close(resultSet, preparedStatement, connection);
        }
        return individualInformationByUidVO;
    }

    /**
     * 通过学生学号uid更新个人信息
     *
     * @param uid                            学生学号
     * @param updateIndividualInformationDTO 更新的数据
     */
    @Override
    public void updateIndividualInformationByUid(Integer uid, UpdateIndividualInformationDTO updateIndividualInformationDTO) {

        Connection connection = null;
        PreparedStatement preparedStatement = null;

        try {
            connection = JDBCUtil.getConnection();
            String sql = "UPDATE student_msg " +
                    "SET phone = ?, email = ?, political_status = ?, is_needy_student = ?, " +
                    "dorm = ?, strength = ? " +
                    "WHERE uid = ?";
            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setString(1, updateIndividualInformationDTO.getPhone());
            preparedStatement.setString(2, updateIndividualInformationDTO.getEmail());
            preparedStatement.setString(3, updateIndividualInformationDTO.getPoliticalStatus());
            preparedStatement.setInt(4, updateIndividualInformationDTO.getNeedyStudent());
            preparedStatement.setString(5, updateIndividualInformationDTO.getDorm());
            preparedStatement.setString(6, updateIndividualInformationDTO.getStrength());
            preparedStatement.setInt(7, uid);

            preparedStatement.executeUpdate();

        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JDBCUtil.close(preparedStatement, connection);
        }
    }
}